home *** CD-ROM | disk | FTP | other *** search
/ BCI NET 2 / BCI NET 2.iso / archives / programming / source / graphicgems4.lha / GemsIV / graph_layout / mswindow.hxx < prev    next >
Encoding:
Text File  |  1995-02-06  |  3.4 KB  |  117 lines

  1. /******************************************************************************
  2. **    TEST FILE FOR graph (Dynamic Layout Alg)
  3. **
  4. **    HEADER - C++ X-WINDOW class library based on Xlib
  5. **
  6. ** Author: dr. Szirmay-Kalos Laszlo (szirmay@fsz.bme.hu)
  7. **       Technical University of Budapest, Hungary
  8. *****************************************************************************/
  9.  
  10. #include <windows.h>
  11. #include <stdio.h>
  12. #include <string.h>
  13. #include <stdlib.h>
  14.  
  15. //******************************************************************
  16. //    CONSTANTS
  17. //******************************************************************
  18. #define WINDOW_WIDTH    400
  19. #define WINDOW_HEIGHT    400
  20. #define FALSE        0
  21. #define TRUE        1
  22.  
  23. //******************************************************************
  24. //    TYPES
  25. //******************************************************************
  26. typedef short  CoOrd;
  27. typedef char * pchar;
  28.  
  29. //===================================================================
  30. class App {        // APPLICATION
  31. //===================================================================
  32. public:
  33.     void        Start( int argc, char * argv[] );
  34.     void        Error( char * mess, int line = -1 );
  35.     void        Warning( char * mess );
  36.     void        Quit();
  37. };
  38.  
  39. extern App app;
  40.  
  41. //===================================================================
  42. class Point {
  43. //===================================================================
  44. private:
  45.     CoOrd x;
  46.     CoOrd y;
  47. public:
  48.             Point( )            { x = y = 0;        }
  49.             Point(CoOrd x0, CoOrd y0)    { x = x0; y = y0;   }
  50.     CoOrd&  X()                    { return x;        }
  51.     CoOrd&  Y()                    { return y;        }
  52. };
  53.  
  54. //===================================================================
  55. class RectAngle {
  56. //===================================================================
  57. private:
  58.     CoOrd hor_pos;
  59.     CoOrd ver_pos;
  60.     CoOrd width;
  61.     CoOrd height;
  62.  
  63. public:
  64.         RectAngle(CoOrd hp, CoOrd vp, CoOrd w, CoOrd h)
  65.           { hor_pos = hp; ver_pos = vp; width = w; height = h;    }
  66.     CoOrd&  HorPos()    { return hor_pos;        }
  67.     CoOrd&  VerPos()    { return ver_pos;        }
  68.     CoOrd&  Width()    { return width;            }
  69.     CoOrd&  Height()    { return height;        }
  70. };
  71.  
  72. //===================================================================
  73. class KeyEvent {
  74. //===================================================================
  75.     WORD    wParam;    // word param
  76.     LONG    lParam;    // long param
  77. public:
  78.         KeyEvent( WORD w, LONG l) { wParam = w; lParam = l; }
  79.     int        GetASCII( void ) { return wParam; }
  80. };
  81.  
  82. //===================================================================
  83. class ExposeEvent {
  84. //===================================================================
  85.     RectAngle  area;
  86. public:
  87.            ExposeEvent( RectAngle * pr )
  88.           :area( *pr ) { }
  89.     RectAngle& GetExposedArea( )    { return area;    }
  90. };
  91.  
  92. //===================================================================
  93. class AppWindow {
  94. //===================================================================
  95.     char        szClassName[14];    // app window name
  96.     HWND        hWnd;            // window handle
  97.     HDC        hdc;            // device context
  98.     PAINTSTRUCT    ps;
  99.     RectAngle    canvas;
  100. protected:
  101.     virtual void    KeyPressed( KeyEvent * ) {}
  102.     virtual void    ExposeAll( ExposeEvent * ) {}
  103.  
  104.     RectAngle    Canvas( void );
  105.     void        RePaint( void );
  106.     void        Text( char * text, Point position );
  107.     void        MoveTo( Point to );
  108.     void        LineTo( Point to );
  109.     void        DrawRectangle( RectAngle& rect );
  110.  
  111. public:
  112.             AppWindow( int argc, char * argv[] );
  113.     long        WindowProc( HWND hwnd, WORD wmsg, WORD wParam, LONG lParam );
  114.     void        MessageLoop( );
  115. };
  116.  
  117.